package com.wx.springboot.step6.es.document;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 搜索中的商品信息
 */

/*
//标示映射到Elasticsearch文档上的领域对象
public @interface Document {
    //索引库名称，mysql中数据库的概念
    String indexName();
    //文档类型，mysql中表的概念
    String type() default "";
    //默认分片数
    short shards() default 5;
    //默认副本数量
    short replicas() default 1;
}
 */
@Data
@Document(indexName = "demo", type = "product",shards = 1,replicas = 0)
public class EsProduct implements Serializable {
    private static final long serialVersionUID = -1L;

    //表示是文档的id，文档可以认为是mysql中表行的概念
    @Id
    private Long id;
    /*
    public @interface Field {
        //文档中字段的类型
        FieldType type() default FieldType.Auto;
        //是否建立倒排索引
        boolean index() default true;
        //是否进行存储
        boolean store() default false;
        //分词器名次
        String analyzer() default "";
    }
     */
    /*
    不需要中文分词的字段设置成@Field(type = FieldType.Keyword)类型
    需要中文分词的设置成@Field(type = FieldType.Text)类型
     */
    @Field(type = FieldType.Keyword)
    private String productSn;
    private Long brandId;
    @Field(type = FieldType.Text)
    private String brandName;
    private Long productCategoryId;
    @Field(type = FieldType.Keyword)
    private String productCategoryName;
    private String pic;
    @Field(type = FieldType.Text)
    private String name;
    @Field(type = FieldType.Text)
    private String subTitle;
    @Field(type = FieldType.Text)
    private String keywords;
    private BigDecimal price;
    private Integer sale;
    private Integer newStatus;
    private Integer recommendStatus;
    private Integer stock;
    private Integer promotionType;
    private Integer sort;
    @Field(type = FieldType.Nested)
    private List<EsProductAttributeValue> attrValueList;
}
